package com.jxufe.hadoop.flowCount;

import java.io.IOException;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

public class FlowReducer extends Reducer<Text, FlowBean, Text, FlowBean> {

	@Override
	public void reduce(Text key, Iterable<FlowBean> values, Context context) throws IOException, InterruptedException {
		long sum = 0;
		long dflow = 0;
		long upflow = 0;
		for (FlowBean bean : values) {
			dflow += bean.getdFlow();
			upflow += bean.getUpFlow();
		}
		sum = dflow + upflow;
		context.write(key, new FlowBean(upflow,dflow,sum));
	}
}
